#include <iostream>
#include <deque>
#include "foreach.h"
#include "ThreadService.h"
#include <boost/foreach.hpp>
#include <sys/time.h>
#include <cstdio>
#include <string>

using namespace std;

std::deque<int> value;
int counter;
void print2()
{
    int x;
    foreach(x, Range(5))
    {
        cout<<x<<std::endl;
    	++counter;
    }
}
void print()
{
    //int x;
    BOOST_FOREACH(int x, value)
    {
        //cout<<x<<std::endl;
    	++counter;
    }
}
int main()
{
	/*counter  = 0;
	for(int x = 0; x< 9000000; ++x)
	{
		value.push_back(5);
		value.push_back(4);
		value.push_back(3);
	}
	{
	struct timeval start;
	struct timezone tz;
	gettimeofday(&start, &tz);
    ThreadService::NewService("printer");
    ThreadService::GetService("printer")->Add(print2);
    ThreadService::GetService("printer")->Join();
    struct timeval end;
	gettimeofday(&end, &tz);

	double startSecond = start.tv_usec/1000000.0;
	double endSecond = (end.tv_sec - start.tv_sec) + end.tv_usec/1000000.0;
	std::cout<<"Time: "<<endSecond - startSecond<<std::endl;
	}
	{
		struct timeval start;
		struct timezone tz;
		gettimeofday(&start, &tz);
	    ThreadService::NewService("printer2");
	    ThreadService::GetService("printer2")->Add(print);
	    ThreadService::GetService("printer2")->Join();
	    struct timeval end;
		gettimeofday(&end, &tz);

		double startSecond = start.tv_usec/1000000.0;
		double endSecond = (end.tv_sec - start.tv_sec) + end.tv_usec/1000000.0;
		std::cout<<"Time: "<<endSecond - startSecond<<std::endl;
	}
    value.clear();

    //ThreadService::Destroy("printer");
    std::cout<<"counter:"<<counter<<endl;
    //ThreadService::DestroyAll();
    //system("pause");
*/

    int x = 0;
    int y = 0;
    int z = 0;
    long long valor;
    std::string c;
    char d;
    c = "lol lol lol lol\n\n\lol\nlol";
    {
        foreach(d , c)
        {
            std::cout<<d;
        }
    }
    {
        foreach(d , c)
        {
            std::cout<<d;
        }
    }
    int valor1 = 0;
    for_range(valor1, 100)
    {
        std::cout<<valor1<<std::endl;
    }
    ///std::cout<<valor<<std::endl;

    return 0;
}
